package com.example.nio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class NIOFileTransferFrom {
    public static void main(String[] args) throws Exception {

        FileInputStream fileInputStream = new FileInputStream("d:\\a.png");
        FileOutputStream fileOutputStream = new FileOutputStream("d:\\b.png");

        FileChannel fileInputStreamChannel = fileInputStream.getChannel();
        FileChannel fileOutputStreamChannel = fileOutputStream.getChannel();

        fileOutputStreamChannel.transferFrom(fileInputStreamChannel, 0 , fileInputStreamChannel.size());
//        fileInputStreamChannel.transferTo(0, fileInputStreamChannel.size(), fileOutputStreamChannel );

        fileInputStream.close();
        fileOutputStream.close();

    }
}
